package com.itmuch.contentcenter.feignclient.fallbackfactory;

import com.itmuch.contentcenter.domain.dto.user.UserDto;
import com.itmuch.contentcenter.feignclient.UserCenterFeignClient;
import com.itmuch.contentcenter.feignclient.fallback.UserCenterFeignClientFallback;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import sun.awt.CausedFocusEvent.Cause;

/**
 * @author caiqian
 * @date 2021/5/8 14:56
 */
@Component
@Slf4j
public class UserCenterFeignClientFallbackFactory implements FallbackFactory<UserCenterFeignClient> {

  @Override
  public UserCenterFeignClient create(Throwable cause) {
    return id -> {
      log.warn("远程 调用 被限流或者 降级",cause);
      UserDto userDto = new UserDto();
      userDto.setWxNickname("default user!");
      return null;
    };
  }
}
